using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Web.UI;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using IWCommunity.Blogs.WebControls;

namespace IWCommunity.WebControls
{
    [ToolboxData("<{0}:ForumsListWebPart runat=server></{0}:ForumsListWebPart>")]
    [XmlRoot(Namespace = "IWCommunity.WebControls")]
    public class ForumsListWebPart:Microsoft.SharePoint.WebPartPages.WebPart
    {
        protected override void CreateChildControls()
        {
            ForumsList fList = new ForumsList();
            fList.ID = "fList";
            fList.Transform.XslName = XslFileName;
            fList.CacheTimeout = _cacheTimeout;
            fList.EnableCaching = _enableCache;
            fList.CacheDebug = _enableCacheDebug;

            this.Controls.Add(fList);         
            
        }
      
        private string _xslFileName;
        [Browsable(true), Category("Miscellaneous"), WebPartStorage(Storage.Shared), FriendlyName("XSL File Name"), Description("Name of the file to use for XSTL tranformation")]
        public string XslFileName
        {
            get
            {
                return _xslFileName;
            }

            set
            {
                _xslFileName = value;
            }
        }

        private int _cacheTimeout;
        [Browsable(true), Category("Miscellaneous"), WebPartStorage(Storage.Shared), FriendlyName("Cache Timeout"), Description("How long (mins) to cache the result HTML for")]
        public int CacheTimeout
        {
            get
            {
                return _cacheTimeout;
            }

            set
            {
                _cacheTimeout = value;
            }
        }

        private bool _enableCache;
        [Browsable(true), Category("Miscellaneous"), WebPartStorage(Storage.Shared), FriendlyName("Enable Cache"), Description("Set to true to enable caching of the html")]
        public bool EnableCache
        {
            get
            {
                return _enableCache;
            }

            set
            {
                _enableCache = value;
            }
        }

        private bool _enableCacheDebug = false;
        [Browsable(true), Category("Miscellaneous"), WebPartStorage(Storage.Shared), FriendlyName("Show Cache Debug"), Description("Adds date and time rendered to part")]
        public bool EnableCacheDebug
        {
            get
            {
                return _enableCacheDebug;
            }

            set
            {
                _enableCacheDebug = value;
            }
        }
    }
}
